/** \b
 * \w与\W  \w与^  \w与$ 之间的位置
 * 
 * \B 则是 \b的反
 * 
 * ?=p p之前的位置
 * 
 * ?!p  除了p以外所有元素之前的位置
 */

const str = '[js] hello.mp4'
let result = str.replace(/\b/g, '#')
console.log(result)   //[#js#] #hello#.#mp4#

result = str.replace(/\B/g, '#')
console.log(result)  //#[j#s]# h#e#l#l#o.m#p#4

result = str.replace(/^|$/g, '#')
console.log(result)  //#[js] hello.mp4#

result = str.replace(/(?=l)/g, '#')
console.log(result)  //[js] he#l#lo.mp4

result = str.replace(/(?!l)/g, '#')
console.log(result)  //#[#j#s#]# #h#ell#o#.#m#p#4#

const str2 = 'Please enter the nine-digit id as it appears on your color - coded pass-key'


result = str2.replace(/\b(\w+)-(\w+)\b/g, function (a) {
    const cash = a.split('-')
    return cash[0] + cash[1].split('')[0].toUpperCase() + cash[1].split('').slice(1).join('')
})
console.log(result)

result = str2.replace(/\B-\B/, '#')
console.log(result)

const passpwd = /(?=.*enter)^[\w\s-]*$/g
result = passpwd.test(str2)
console.log(result)
